package com.myown.dto.json;

import com.myown.exception.enums.ExpectionEnum;

/**
 * 前后台json传值模板 <p>
 * @author lincky
 * @version v1.0.0
 */
public class JsonResult<T> {

    // 数据状态模型
    private StatusModel statusModel;

    // 数据
    private T data;

    /**
     * 警告：使用无参构造方法，务必置属性 <p>
     */
    public JsonResult() {
    }

    public JsonResult(T data) {
        this.statusModel = new StatusModel(ExpectionEnum.SUCCESS);
        this.data = data;
    }

    public JsonResult(StatusModel statusModel) {
        this.statusModel = statusModel;
    }

    public JsonResult(StatusModel statusModel, T data) {
        this.statusModel = statusModel;
        this.data = data;
    }

    public StatusModel getStatusModel() {
        return statusModel;
    }

    public void setStatusModel(StatusModel statusModel) {
        this.statusModel = statusModel;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "JsonResult{" +
                "statusModel=" + statusModel +
                ", data=" + data +
                '}';
    }
}
